package com.sziit.se.highconcurrency.order.application.feignclient;

import com.sziit.se.highconcurrency.common.result.DataResult;
import com.sziit.se.highconcurrency.common.result.Result;
import com.sziit.se.highconcurrency.order.application.entity.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotBlank;


//当不启用eureka时，可用url方式直接指定访问地址
//@FeignClient(name = "product-service", url = "http://${product-service.nodeIp}:8888")
//当部署了eureka时，不用指定url，通过eureka注册中心做服务发现
@FeignClient(value = "product-service")
public interface ProductFeign {
    @GetMapping("/product/query-by-id")
    DataResult getProductById(@RequestHeader("Authorization") String token, @RequestParam(value = "productId") String productId);

    @PutMapping("/product/update-by-id")
    DataResult updateProductById(@RequestHeader("Authorization") String token,
//                                 @RequestHeader("Content-Type") String contentType,
                                 @RequestParam("productId") @NotBlank(message = "productId为空") String productId,
                                 @RequestParam("productName") String productName,
                                 @RequestParam("inventory") Integer inventory,
                                 @RequestParam("price") Float price,
                                 @RequestParam("image") MultipartFile image);

    @PutMapping("/product/inner/update-inventory")
    DataResult updateProductInventory(@RequestHeader("Authorization") String token,
                                      @RequestParam("productId") String productId,
                                      @RequestParam("inventory") Integer inventory);
}
